package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.ProductModelSpecValue;
import com.nbsaas.boot.product.api.domain.response.ProductModelSpecValueResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 商品模型规格值-实体对象转化成响应对象
*/

public class ProductModelSpecValueResponseConvert  implements Converter<ProductModelSpecValueResponse,ProductModelSpecValue> {

    @Override
    public ProductModelSpecValueResponse convert(ProductModelSpecValue source) {
        ProductModelSpecValueResponse  result = new  ProductModelSpecValueResponse();
        BeanDataUtils.copyProperties(source, result);

                    try {
                        if(source.getSpec()!=null){
                            result.setSpecName(source.getSpec().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getSpec()!=null){
                        result.setSpec(source.getSpec().getId());
                    }
        return result;
    }

}

